﻿@using FujiyBlog.Core.DomainObjects
@model FujiyBlog.Core.DomainObjects.RoleGroup

@{
    Layout = MVC.Admin.User.Views._Layout;
    ViewBag.Title = (Model.Id != 0 ? "Edit" : "Add") + " Role Group";
}

<h2>@(Model.Id != 0 ? "Edit" : "Add") Role Group</h2>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>RoleGroup</legend>

        @if (Model.Id != 0)
        {
            @Html.HiddenFor(model => model.Id)
        }
        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
        @if (string.Equals(Model.Name, "Anonymous", StringComparison.OrdinalIgnoreCase))
        {
            @Html.DisplayTextFor(model => model.Name)
        }
        else
        {
            @Html.EditorFor(model => model.Name)
        }
            
            @Html.ValidationMessageFor(model => model.Name)
        </div>

        <div class="role-category">
            <ul id="roles-list">
            @foreach (Role role in Enum.GetValues(typeof(Role)))
            {
                <li><input type="checkbox" name="roles" value="@role" @(Model.Roles.Any(x => x == role) ? "checked=checked" : string.Empty) />@role</li>
            }
            </ul>
        </div>

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
